"""
Author : Mr.Sun
DateTime : 2022/10/10.10:39
FileName : test.py
Desc :
"""

from core.OperateSqlite import sqliteOperate

sql = "select key_word, priority from key_words ;"
response = sqliteOperate().search_data(sql)
key_words = [{"keyword": temp[0], "priority": temp[1]} for temp in response]
key_1 = []
key_2 = []
key_3 = []

for i in key_words:
    if i['priority'] == 1:
        key_1.append(i['keyword'])
    if i['priority'] == 2:
        key_2.append(i['keyword'])
    if i['priority'] == -1:
        key_3.append(i['keyword'])

print(key_1)
print(key_2)
print(key_3)

key = ''
title = "2022年市哈尔滨教师阿城区黑龙江事业公告1234"
for key_3_temp in key_3:
    if key_3_temp in title:
        break
    for key_1_temp in key_1:
        if key_1_temp in title:
            key = key_1_temp
            break
        for key_2_temp in key_2:
            if key_2_temp in title and key_1_temp not in title:
                key = key_2_temp

print(key)
